package com.darren.framework.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Table;

import org.hibernate.annotations.ResultCheckStyle;
import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;

import com.alibaba.fastjson.annotation.JSONField;

@Entity
@Table(name = "d_users")
@SQLDelete(sql = "update d_users set is_delete = true where id=?", check = ResultCheckStyle.COUNT)
@Where(clause = " is_delete  != true ")
public class User extends BaseEntity implements Serializable {

	private static final long serialVersionUID = 2861478466077717714L;

	@Id
	@Column(name = "id",columnDefinition = "bigint comment '主键id'")
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	
	/**
	 * 用户帐号，最大长度50个字符
	 */
	@Column(name = "account", columnDefinition = "varchar(50) NOT NULL comment '用户帐号，最大长度50个字符'")
	private String userAccount;
	
	/**
	 * 用户密码，最大长度100个字符,
	 */
	@Column(name = "password",columnDefinition = "varchar(100) NOT NULL default '' comment '用户密码，最大长度100个字符'")
	private String password;
	
	/**
	 * 姓名，最大长度30个字符
	 */
	@Column(name = "name", columnDefinition = "varchar(30) default '' comment '姓名，最大长度30个字符'")
	private String name;	

	/**
	 * 年龄
	 */
	@Column(name = "age", columnDefinition = "int default 0 comment '年龄'")
	private Integer age;

	/**
	 * 性别
	 */
	@Column(name = "gender", columnDefinition = "varchar(5) default '' comment '性别'")
	private String gender;

	/**
	 * 生日
	 */
	@JSONField(name="birthday",format="yyyy-MM-dd")
	@Column(name = "birthday",columnDefinition = "datetime default NULL comment '生日'")
	private Date birthday;
	
	/**
	 * 手机号码
	 */
	@Column(name = "mobile",columnDefinition = "varchar(20) default '' comment '手机号码'")
	private String mobile;
	
	/**
	 * 邮箱
	 */
	@Column(name = "email",columnDefinition = "varchar(60) default '' comment '邮箱'")
	private String email;
	
	@ElementCollection(fetch = FetchType.LAZY)
	@JoinTable(name = "d_emails",joinColumns = @JoinColumn(name = "id"))
	@Column(name = "emails")
	private List<String> emails = new ArrayList<String>();
	
	/**
	 * 微信
	 */
	@Column(name = "wechat",columnDefinition = "varchar(150) default '' comment '微信'")
	private String wechat;
	
	/**
     * 用户类型，是否超级用户：true是；false 否
     */
    @Column(name = "superuser",columnDefinition = "tinyint default 0 comment '用户类型，是否超级用户：true是；false 否'")
	private boolean superuser = true;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUserAccount() {
		return userAccount;
	}

	public void setUserAccount(String userAccount) {
		this.userAccount = userAccount;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public List<String> getEmails() {
		return emails;
	}

	public void setEmails(List<String> emails) {
		this.emails = emails;
	}

	public String getWechat() {
		return wechat;
	}

	public void setWechat(String wechat) {
		this.wechat = wechat;
	}

	public boolean isSuperuser() {
		return superuser;
	}

	public void setSuperuser(boolean superuser) {
		this.superuser = superuser;
	}
	
}
